import java.util.Scanner;

public class Main {
    public static void main(String[] args) {//P1425
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        if(d<b) {
            int f = d + 60 - b;
            int e = c - a - 1;
            System.out.print(e + " ");
            System.out.println(f);
        }else {
            int e = c - a;
            int f = d - b;
            System.out.print(e + " ");
            System.out.println(f);

        }
    }
}

/*
import java.util.Scanner;//P5712
public class Main {
 public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a=sc.nextInt();
if(a<=1){
System.out.print("Today, I ate "+a+" apple.");
 }else {
 System.out.print("Today, I ate "+a+" apples.");
 }
}
}
 import java.util.Scanner;//P1047
 public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int roadLength = sc.nextInt();
        int number = sc.nextInt();
        int[] start = new int[number];
        int[] end = new int[number];
        for (int i = 0; i < number; i++) {
            start[i] = sc.nextInt();
            end[i] = sc.nextInt();
            }
            int[] tree = new int[roadLength + 1];
            for (int i = 0; i < tree.length; i++) {
                tree[i] = 1;
            }

            for (int i = 0; i < number; i++) {
                for (int j = 0; j < tree.length; j++) {
                    if (j >= start[i] && j <= end[i]) {
                        tree[j] = 0;
                    }
                }
            }
            int count = 0;
            for (int i = 0; i < tree.length; i++) {
                if (tree[i] == 1) {
                    count++;
                }
            }
            System.out.println(count);
        }
    }
    import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int count=0;
        for (int i = 1; i <= a; i++) {
            String[] str = (i + "").split("");
            for (int j = 0; j < str.length; j++) {
                if (str[j].equals(String.valueOf(b))){
                    count++;
                }
            }
        }
        System.out.println(count);
    }
}
*/

